﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //链接字符串
            string k = "server =.;database=zcm;uid=sa;pwd=123456";
            //声明链接对象
            SqlConnection conn = new SqlConnection(k);
            //打开链接对象
            conn.Open();
            //声明SQL语句
            string sql = "insert into student values(3,'小张',19,'女','福建')";

            //声明指令对象
            SqlCommand cmd = new SqlCommand(sql, conn);
            //执行添加语句
            int a = cmd.ExecuteNonQuery();
            Console.WriteLine(a);
            //试用指令对象执行SQL
            // SqlDataReader sdr = cmd.ExecuteReader();

            // while (sdr.Read())
            //{
            // string name = (string)sdr["name"];
            // int age = (int)sdr["age"];
            // string sex = (string )sdr["sex"];
            //string address = (string )sdr["address"];
            // string pwd = (string)sdr["pwd"];

            //Console.WriteLine(name+"/t"+age+"/t"+sex+"/t"+address+"/t"+pwd+"/t");
            // }
        }
    }

   
}
